2

I am very new to GIS toolings. So sorry, my research with search and google, could not help me. Maybe since the lack of the right key words.

I try to import existing ESRI shapefiles into a SQL database.

Are there any (open source) java libraries, which provide me such functions? I need the features and the vertexes of the polygons in the database.

What classes should I look for in the library?

Are there any examples of how to do it?

Also are examples available about the needed SQL data types and tables?

cilap
  • 2,215
  • 1
  • 25
  • 51
  • Maybe [this question](http://stackoverflow.com/questions/14242111/reading-an-esri-shapefile-from-a-zip-file-during-runtime-in-java-datastorefind) helps you: it uses [geotools](http://stackoverflow.com/questions/tagged/geotools) and [jts](http://tsusiatsoftware.net/jts/main.html) – DaniEll Jan 16 '15 at 12:00

1 Answers1

0

What kind of SQL database do you have? PostGIS, an extension to PostgreSQL, is the probably the best solution if you're starting from scratch. PostgreSQL provides a geometry field type already, and PostGIS adds projection support, spatial processing, and includes a utility to import shapefiles.

If you want a file-based database, you can use Spatialite, an extension to SQLite, instead. If you're already using a different database, there are spatial features in MySQL, Microsoft SQL Server, and Oracle. If you don't need spatial processing and projection support, you can convert to Well-Known Text using the free QGIS (GUI-based) or GDAL (programmatically) and store it in a text field in any database. I'd need more information about your project to give you a better answer.

dericke
  • 290
  • 4
  • 13
  • do you have examples of how to add features and especially vertexes to the database? – cilap Jan 24 '15 at 02:05
  • I'm a little confused by what you mean. Well-Known Text, stored in a text field, is the simplest of the methods I gave, and even that stores features made of vertices. You can't really have a feature without at least one vertex. An example of WKT, from the Wikipedia article: POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)) Each of those pairs of numbers is the X and Y coordinate of a vertex, and together they make a polygon feature. I can't give an example of how to save it without knowing what database you are using. – dericke Jan 24 '15 at 08:28
  • I have a set of shape files, but the postgis only imports some references to polygones. So what I am missing to get the polygones itself. Since I need a lookup if: a address converted to long/lat is in one of the specific polygones of the provided shape files – cilap Jan 28 '15 at 22:41
  • How did you import the shapefiles? Two of the most common methods are using `shp2pgsql` or by using QGIS. You might also try downloading [OpenGeoSuite](http://boundlessgeo.com/solutions/opengeo-suite/download/), which includes both the command-line and graphical versions of shp2pgsql. The graphical option is probably the easiest way to load your data in. – dericke Feb 04 '15 at 19:36