Tuesday, June 30, 2015

Geoserver create a new layer using REST API


I'am using Geoserver since, well a long time now.  This post is going to be a collection of THINGS that you might want to do with Geoserver.  Sometime errors occur when trying to do something with Geoserver with the REST API and those I have posted aswell.


Goal adding a PostGIS table using the Geoserver REST API

COMMAND:
curl -v -u yourUserName:PWD -XPOST -H "Content-type: text/xml" -d "<featureType><name>TABLENAME</name><nativeCRS>EPSG:3857</nativeCRS><srs>EPSG:3857</srs><enabled>true</enabled></featureType>" http://localhost:8080/geoserver/rest/workspaces/YOURWORKSPACENAME/datastores/DATASTORENAME/featuretypes

Errors   :java.io.IOException: Error occured calculating bounds for someTableName

  • SOLUTION_  permissions on PostGIS tables were incorrect same user as registered in the DB connection must be used when creating a new layer


Saturday, June 6, 2015

How to fix pyshp error reading shapefile

I had a Shapefile I was trying to read using the great pyshp library but it kept shooting out and Invalid Argument Error.

After some web searching it came down to pyshp being very picky about the Shapefile format.  The true cause I still do not know what was wrong.  My Shapefile was created using QGIS, has valid geometries and no problems identifiable in ArcGIS or QGIS.   Due to other experiences using pyshp sometimes if a field value is NULL or empty it causes some error.

The solution:

ogr2ogr  new_shapefile.shp original.shp


the new_shapefile.shp  will work using the pyshp   ShapeRecords()  function.

Possible other problems that pyshp sometimes encounters:

  1. NULL value in field
  2. '' empty in field
  3. .dbf encoding  (Latin1, UTF-8)
Anyway if you know of a cause please let me know.

cheers
michael