4

What is the best option, if any, to upload a vector format like GeoJson, and or GML to Geoserver?

The environment from which to upload will be a client web-application, so i cannot use curl. In the backend, i am using a C#-Proxy to connect to Geoserver.

Do I have to convert the file to shape (*.shp) first in some way, which i am able to upload via REST, or is there an option to load the data directly?

On the docs, there is an option for uploading property files, but i cannot find any documentation on it and am not shure about how to use that or if it can help solving my problems.

  • 1
    Perhaps the importer module works for you docs.geoserver.org/latest/en/user/extensions/importer/…. Examples are using curl but GeoServer does not know who is sending the GET/POST/PUT requests so use your favorite method. GeoJSON and GML are not supported as datastores on the server side and they would be slow anyway. I would study the CSV to PostGIS example. Perhaps it could be modified to import also GeoJSON and GML into PostGIS. Another option could be to upload data into PostGIS with some other tool and use REST for creating new layers into GeoServer. – user30184 Aug 14 '15 at 7:17
  • 2
    If you are using a web client may be WFS-T is more suited to this – Ian Turton Aug 14 '15 at 8:17
  • Thank you for the comments! While the database-way seems to be able to cover it as a whole, WFS-T seems to be another fair option. What would be the best way to write transaction queries then? Is there any javascript library for generating WFS-T XML? Writing all these xml code by hand seems to be pretty ugly. – hnrch Aug 14 '15 at 8:25
  • First question is if you want to create new layers or add data to existing ones. With WFS-T you can't create layers. – user30184 Aug 14 '15 at 8:54
  • Yes, I need to create a new layer from a KML file. So maybe I can manually add a datastore and featuretype via REST, and then use WFS-T to add data from KML / GeoJSON or similar? – hnrch Aug 14 '15 at 9:38
2

As user30184 said, the importer extension has been designed exactly for this job, and will convert the data into the format of the chosen target store (e.g., will import the data into postgis or oracle for you).

WFS-T is more geared towards single feature editing than "mass import" and can only handle GML anyways.

  • Thanks! So, I create a database-connected datastore, push my data (gml, kml, shp, csv or whatever) to this datastore via Importer to Geoserver and it will generate the layers, right? Is the Importer automatically creating new tables in the database for me? – hnrch Aug 15 '15 at 14:30
  • I checked all the details of the Importer API here and it seems to be solving all my needs. Thanks again for pointing me in the right direction! – hnrch Aug 15 '15 at 19:42
  • Hi @hnrch , I am using the geoserver rest api importer to do the same thing. However, when I posted an importer, it returns directory list of my geoserver data directory instead of a description of the importer. Why? – zhangjinzhou Jun 21 '17 at 16:25
  • @zhangjinzhou can you post a new issue for that describing the whole problem and post the link here. thanks. – hnrch Jun 22 '17 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.