I have written a simple tool to ingest
shapefiles into Accumulo. I know that this already exists
through the geomesa ingest tool. However, it is limited. It
only does one file at a time. I know that I can batch it in a
script, but this doesn’t work either. I want to ingest a large
set of shapefiles into a single feature within a single
Accumulo table. The geomesa ingest tool will not append to an
existing feature. So it won’t work.
Therefore, I have simply looked at what the
geomesa ingest tool does and I tried to mimic it. It works
great except for one thing. I am having problems with the
coordinate reference system.
I am essentially doing the following:
1. Connect
to the Accumulo database. If the table does not exist already
it will be created. I get an AccumuloDataStore
out of this.
AccumuloDataStore dataStore
= (AccumuloDataStore)DataStoreFinder.getDataStore(connectionInfo);
For each shapefile in a folder.
1. Create
a SimpleFeatureCollection from
the shapefile
2. Get
the Schema (SimpleFeatureType)
from the SimpleFeatureCollection
3. Get
a SimpleFeatureStore from the AccumuloDataStore. If this fails (I
assume because the feature did
not already exist in the database) then I create the feature
using dataStore.createSchema(shapefileSchema)
before getting the feature source.
SimpleFeatureStore featureStore
= (SimpleFeatureStore)dataStore.getFeatureSource(featureName);
4. Add
the shapefile features to the featureStore.
((AccumuloFeatureStore)featureStore).addFeatures(shapefileFeatures);
Now this all works if the .prj files specify the CRS as WGS84
geographic which is apparently the default.
However, I have shapefiles that are
geographic NAD83. I can tell that the first two steps that I
do for the shapefile are working because when I print out the
result of shapefileSchema.getCoordinateReferenceSystem().toWKT()
I can see that it
gives me NAD83 as I expect.
The problem is that after I go through all
4 steps with the first shapefile and then get back, the next
shapefile fails on step 4. It says that there is a mismatch of
the Coordinate Reference Systems.
Sure enough, if I print out the reference
system after step 3 using featureStore.getSchema().getCoordinateReferenceSystem().toWKT() it says that it is
WGS84.
This shows me that either the getFeatureSource in step 3 is not
pulling the CRS from Accumulo, or the addFeatures
in step 4 is not adding the CRS to Accumulo. Therefore, my
code thinks that no matter what the CRS was in the shapefiles
the CRS is WGS84 in Accumulo.
Anybody have any idea what is going on
here?
Note: I am using Geomesa 1.1.0-rc.5 with
Accumulo 1.6.1
Thanks,
Nathan Mercer