Tag Info

Hot answers tagged

13

A da.searchcursor should work for you. for row in arcpy.da.SearchCursor("path2data", ["SHAPE@WKT"]): print row[0] POINT Z (-119.53753379999995 49.854383300000052 303.14500000000407) doc here: http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001t000000 Note: SHAPE@JSON, SHAPE@WKB, and SHAPE@WKT tokens were made available ...


12

The geopy module provides the Vincenty formula, which provides accurate ellipsoid distances. Couple this with the wkt loading in Shapely, and you have reasonably simple code: from geopy import distance from shapely.wkt import loads line_wkt="LINESTRING(3.0 4.0, 3.1 4.1)" # a number of other elipsoids are supported distance.VincentyDistance.ELLIPSOID = ...


12

As far as I know WKT doesn't really support any kind of label as it just represents the geometry itself. What you could do is however just store it as comma separated list eg: feature1label, {WKT string} feature2label, {WKT string} You should then be able to display this with X GIS program. QGIS can open and display text files with a comma separated ...


10

I was able to export to CSV, using other than a comma, by separating the layer creation options in the Save As.. dialog with linebreaks. Neither comma, nor space-separating them (even when they were in quotes) worked, but the linebreaks did the trick. To emphasize.. THIS APPROACH WORKED (linebreak-separated): GEOMETRY=AS_WKT SEPARATOR=SEMICOLON ...


9

Indeed there is! Look here for how to achieve it with the Add Delimited Text Layer plugin. Essentially you create a CSV file (although you should use a delimiter other than comma), where one column is the WKT representation of your geometry. Then when you select that file in the plugin, it picks up that there is a WKT column, and does the right thing. I ...


8

Well known text for geometry is defined in OGC 01-103r4 (amongst other places). Section 7 of that document provides the syntax. There is also a list of SQL functions relating to those in Part 2 of the Simple Features spec (also an OGC product). The ISO documents are just a more expensive way to get much the same thing. There are useful extensions such as ...


7

Using the IWkb interface does a nice job at converting between an IGeometry and WKB. From a WKB you can use the Microsoft.SqlServer.Types library to convert a WKB to SqlGeometry then back to WKT. IWkb wkb = geometry as (IWkb); //(Where geometry is an instance of IGeometry) byte[] wkb_bytes = new byte[wkb.WkbSize]; int byte_count = wkb.WkbSize; ...


7

The OGR Spatial Reference part of GDAL should do the trick. capooti provided an excellent answer to another question which demonstrates how to peform the translation from a shapefile to WKT. You may also want to check out the class reference. The reverse is simply: from osgeo import osr srs = osr.SpatialReference() wkt_text = ...


7

There are no built-in checks for this in OpenLayers, but it should be possible to implement one quite easily. The Polygon class has a Components property which holds several LinearRings, the first ring beeing the outer ring and the consecutive ones (if any) represents holes. To find self-intersections you could make a function that loops the induvidual ...


6

I have looked at your data and the book example, the problem is that there are three invalid polygons in data that are processed in the book: GSHHS_l_L1.shp ID = 92-W POLYGON ((-180.0 71.514793999999995,-179.69008299999999 71.577888999999999,-178.648889 71.577416999999997,-178.40644399999999 71.549916999999994,-177.406306 71.244167000000004,-177.877444 ...


6

How about using GDAL's OGR .NET bindings? http://bjarte.com/post/gdal-in-csharp and its KML driver through libkml http://www.gdal.org/ogr/drv_libkml.html Alternatively, you could use libkml directly.


6

Shapely deals with geometric objects, not features or collections of features. See the manual on shape(). Your code (with JSON) could be: import json from shapely.geometry import shape f = open('wijken.json', 'r') js = json.load(f) f.close() for f in js['features']: s = shape(f['geometry']) ...


5

You can use MapScript (part of MapServer) to make images from any sort of geometry. With (e.g.) MapScript for PHP, you could build a geometry from a WKT string with ShapeObj ms_shapeObjFromWkt(string wkt), make the style look good, then render an image object with imageObj draw() (see an example). There are different flavours of Mapscript, including for ...


5

I've run your coordinates through gdaltransform: $ gdaltransform -s_srs EPSG:32017 -t_srs EPSG:4326 759232.003438, 1149854.52147 -77.6116223688997 43.1517747887723 0 And it appears to come up with the right answer. This means that proj4 (which GDAL and PyProj are based on) is doing the right thing. Sometimes these sorts of errors can be caused by ...


5

When in doubt go to the OGC Spec (http://portal.opengeospatial.org/modules/admin/license_agreement.php?suppressHeaders=0&access_license_id=3&target=http://portal.opengeospatial.org/files/index.php?artifact_id=25355) which when you follow through all the BNF on page 53 indicates that a period or a comma are acceptable decimal points.


5

If you want to use PostGIS to do the conversion, you can choose from the following functions: bytea WKB = ST_AsBinary(geometry); text WKT = ST_AsText(geometry); geometry = ST_GeomFromWKB(bytea WKB, SRID); geometry = ST_GeometryFromText(text WKT, SRID); More: http://postgis.net/docs/manual-1.5/ch04.html#OpenGISWKBWKT


5

Looks like you have a self-intersection, which SQL Server no likey. I'm surprised it even got loaded into the database in the first place. Try running MakeValid() and see what it does to the shape. You don't have to test it on the original data, just make a new one on the fly in Management Studio. What's interesting is that SQL Server will plot it: But ...


5

The OGC WKT and WKB specifications never explicitly addressed how to encode higher dimensionality, so it would not be surprising if Oracle either (a) did not encode those dimensions at all or (b) did so in a way that is not consistent with formats PostGIS can ingest. Absent any examples of Oracle output, I'm just guessing. You might find that a ...


5

Well Known Text is not meant for saving layers like shape files that consists of many objects. WKT defines how to represent geometry of one object. That geometry could be single or multi part. Multi part geometries mean that geometry of one object consists of many parts. For example Hawaiian Islands could be represented as one object but it consists of many ...


5

Ogr2ogr translates vector data sources between different formats. Shape file is one kind of data source format but WKT is not. WKT is just a way to represent geometries in a human understandable way. Data source consists of features/objects that consists of a geometry and attributes. The ogr2ogr command you specified in your previous question translates ...


5

why not use ST_GeomFromGeoJSON which takes as input a geojson representation of a geometry and outputs a PostGIS geometry object. ST_AsGeoJSON, the inverse see Creating GeoJSON Feature Collections with JSON and PostGIS functions or ST_GeomFromGeoJSON from OpenGeo. To convert to WKT, use ST_AsText , the reverse of ST_GeomFromText() which return the ...


5

As the geometry is in the WTK-format and is of the type polygon, you will specify this in your vrt-file. So your vrt file should look someting like this: <OGRVRTDataSource> <OGRVRTLayer name="parcel"> <SrcDataSource>parcel.csv</SrcDataSource> <GeometryType>wkbPolygon</GeometryType> ...


4

If you can work with Java, the JTS Topology Suite can perform such translation by using the classes com.vividsolutions.jts.io.WKBReader and com.vividsolutions.jts.geom.Geometry. A code like this should get the geometry in Well-Known Text format: String wkbString = "0101000000cdcccccc170d2241b81e859bcb405241"; // geometry in WKB format to be translated to ...


4

http://dev.mysql.com/doc/refman/5.0/en/gis-wkb-format.html For example, a WKB value that corresponds to POINT(1 1) consists of this sequence of 21 bytes (each represented here by two hex digits): 0101000000000000000000F03F000000000000F03F The sequence may be broken down into these components: Byte order : 01 WKB type : 01000000 X : ...


4

do you have to use that mask or could you load a shapefile (from say Natural Earth) and then do your look ups against those polygons? If you can then GeoTools (http://docs.geotools.org/stable/userguide/examples/) should be able to do this quite easily. In fact with a little more work you should be able to export the landmask from netCDF into a GeoTiff and ...


4

In the past, I've used Sharpmap's converter, but I had to get to WKB first. I don't know if it is the best option now. SharpMap.Geometries.IGeometry sharpGeom = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse(geombytes); wkt = SharpMap.Converters.WellKnownText.GeometryToWKT.Write(sharpGeom); I also don't know of where the current SharpMap ...


4

You might try referencing the Microsoft.SqlServer.Types assembly (which I believe is included with the free Sql Server Express edition), then use STGeomFromWKB static method to create a microsoft geometry, which could then be converted into WKT using STAsText. Also note that while Microsoft catches a lot of flak about being proprietary, they do offer ...


4

Looking here, you can use the +pm parameter to specify your own prime meridian relative to Greenwich, so using this command: $ cs2cs +proj=latlong +datum=WGS84 +to +proj=latlong +datum=WGS84 +pm=180dW I get this: 0.0 0.0 180dE 0dN 0.000 1 0 181dE 0dN 0.000 179 0 359dE 0dN 0.000 -179 0 1dE 0dN 0.000 Which seems to be what you want. I'm not ...


4

The excellent Java Topology Suite has been/is being ported to Javascript: https://github.com/bjornharrtell/jsts you could try using its Geometry.isValid() method to test the polygon for correctness before submitting it to the server.


4

I'm not equipped to confirm this, but this page documenting SearchCursor (arcpy.da), discussing the field_names parameter, notes the following: FROM ArcGIS Help 10.1 - SearchCursor (arcpy.da) Additional information can be accessed using tokens (such as OID@) in place of field names: SHAPE@WKT —The well-known text (WKT) representation for OGC ...



Only top voted, non community-wiki answers of a minimum length are eligible