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?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

do you have examples of how to add features and especially vertexes to the database?
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.
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
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, which includes both the command-line and graphical versions of shp2pgsql. The graphical option is probably the easiest way to load your data in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.