Hot answers tagged

48

Look at Are there any online WKT editors? GeoJSON and WKT OpenLayers vector formats GeoJSON geojson.io GeoJSONLint GeoJSON viewer and others WKT Wicket OpenStreetMap WKT Playground


25

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 at ...


19

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 ...


17

Generally speaking, this is called hex-encoded WKB. This specific example is the extended version, called EWKB, since it has SRID=4326 as found by E6100000. WKB can be viewed in a few forms. The hex-encoded string representation is the most common, which if it is actually text can be converted using a simple ::geometry cast: SELECT ST_AsText(wkb_geometry), ...


16

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 ...


16

Go to Layer -> Add Layer -> Add Delimited Text Layer. You should be able to find the csv file you have, give it a layer name, and choose file format as CSV. In the Geometry Definition, you will have to use Well known Text (WKT) by ticking that box. Set the Geometry field to the column you want, and you might want to set the Geometry type as Polygon. See ...


13

There are two possibilities here (see http://en.wikipedia.org/wiki/Well-known_text for more possibilities): LineString - LINESTRING (30 10, 10 30, 40 40) MultiLineString - MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10)) Currently you have LINESTRING and (( which is wrong. UPDATE There is also a problem with the commas as Jason says, ...


12

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; wkb....


11

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 ...


11

Since Shapely 1.3 you can give dumps() a rounding_precision keyword arg: >>> from shapely.geometry import Point >>> from shapely.wkt import dumps >>> dumps(Point(1.00000000000001, 0.0)) 'POINT (1.00000000000001 0)' >>> dumps(Point(1.00000000000001, 0.0), rounding_precision=4) 'POINT (1 0)'


11

I am not sure if this was actually part of QGIS 2.x since I always used the getWKT plugin. But the WKT is accessible from the Identify window context menu: Result: wkt_geom id OBJECTID ID_0 ISO NAME_0 ID_1 NAME_1 ID_2 NAME_2 HASC_2 CCN_2 CCA_2 TYPE_2 ENGTYPE_2 NL_NAME_2 VARNAME_2 Shape_Length Shape_Area MultiPolygon ((...


10

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 ...


10

Take a look at Wicket, it's awesome: http://arthur-e.github.io/Wicket/sandbox-gmaps3.html The demo sandbox might be enough for you, if not you could probably use it to develop a simple Javascript app.


10

While PostGIS can handle mixed geometry types, this won't help you for QGIS. Regardless of their source all layers in QGIS can only be of a single geometry type.


10

You should be able to use STAsText: https://msdn.microsoft.com/en-us/library/bb933977.aspx So you could create a new table: CREATE TABLE wkt_export as SELECT *, RoadGeometry.STASText() as WKT FROM table_name; Then export it and use the WKT field to load as a csv file to QGIS. You could also try connecting directly to the server:


9

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 ...


9

It looks like a new and better supported JS WKB parsing library has since appeared. https://github.com/cschwarz/wkx I've been able to use it to convert WKB directly from postgres into JS objects that can be mapped in the browser. You'll need to include https://github.com/cschwarz/wkx/blob/master/dist/wkx.js in your webpage for this to work. // Required ...


8

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']) ...


8

You've caught a lot of the differences. Esri never adopted the WKIDs for the map projection algorithms or parameter names so those are all different. We didn't agree with how carefully defined the parameter definitions are. Ours are more generalized. We don't support TOWGS84 nor some of the newer keywords. When we compare strings (names), we ignore the ...


8

If you've already got WKT, then you might considering using the JavaScript library, Wicket, to go straight from your WKT to Leaflet features. As this example shows, you can pass in a WKT string and a style/options object, and Wicket will return a feature object you can attach directly to a Leaflet FeatureGroup, etc. This example assumes two things: 1) You ...


8

Oracle Spatial and Postgis both have their own pros and cons. While dealing with the spatial data Postgis always outperform Oracle Spatial. I have been working for last 2 year on Oracle Spatial and i recently switched to PostGIS, and i saw a huge performance difference in both of them. The reason why it perform much faster is because spatial data parsing. ...


7

The only solution pure javascript solution I've found so far (and I did not try) is https://github.com/thejefflarson/wkb.js. It's only an incomplete WKB parser (it converts WKB to a js object you can transform to WKT) An alternative way to wkb on javascript side can be the experimental twkb (not a standard at the moment) http://blog.jordogskog.no/2013/05/05/...


7

You can do this with OpenLayers. Please have a look at the Vector Format's sample. Just select 'Well Known Text' from the drop down, and draw your shape. You will get your shape in WKT format. For the Editing/Modifying functionality, have a look at the Modify Feature Example. This shows how you can modify an existing geometry. You could copy the code to ...


7

If Python is your thing then you can use GeoMet. It's a Python module that converts GeoJSON to WKT/WKB and vice versa. You can install it directly from the github repository using pip $ pip install git+git://github.com/larsbutler/geomet.git Here is a sample conversion: >>> from geomet import wkt >>> point = {'type': 'Point', 'coordinates'...


7

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> <...


7

GDAL has methods for that. From http://www.gdal.org/classOGRSpatialReference.html: "contains methods for converting between this object organization and well known text (WKT) format". ExportToWkt is probably what you need "Convert this SRS into WKT format. Note that the returned WKT string should be freed with OGRFree() or CPLFree() when no longer ...


7

Technically, I think you have two questions. The first is just what's the WKT for this PROJ.4 string. The second is about how a CRS WKT is structured. An answer to the second question is probably too long for Stackexchange, but I've put some pointers below. In answer to the first (should be single line, formatted into multiple lines for readability), I'm ...


7

Not sure if this fills your needs but you can (and always could) get the WKT from the field calculator by adding a virtual layer with: geomToWKT( $geometry )


6

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 ...


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.


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