4
votes
2answers
117 views

How to access Shapefile metadata using OGR?

I'm trying to use ogrinfo to get some details on a shapefile I downloaded. Currently, the only way I know how to do this is to load it into QGIS and manually click around to find any information on ...
2
votes
3answers
76 views

Shapefile with overlapping polygons: calculate average values

I have a very big polygon shapefile with hundreds of features, often overlapping each other. Each of these features has a value stored in the attribute table. I simply need to calculate the average ...
1
vote
2answers
53 views

Ogr2ogr - shape to postgis - is there a way to use and preserve an existing primary key?

I've been struggling with this for a while, tried a few different ideas inspired by these pages: http://www.gdal.org/ogr2ogr.html http://www.gdal.org/ogr/drv_pg.html ...
1
vote
2answers
234 views

How to change shapefile longitude from -180 - 180 to 0 - 360?

I have a shapefile of world countries, with longitude between -180° and 180°. How can I change the shapefile (eg. with ogr2ogr) for having longitude between 0 and 360°. Following OSGEO/Trac ...
1
vote
0answers
200 views

Importing Census TIGER Shape Files to SQL Server 2012?

I've been doing my research on how to import shape files into Microsoft SQL Server 2012. and am still unable to figure out how to do it after hours of playing around with it. I'll document what I've ...
1
vote
1answer
145 views

Automatically determine polygon overlap 'islands'

I have a shapefile with many polygons. Some partly overlap with each other, some are not overlapping. I'm considering a polygon to be overlapping given a minimum area of overlap. 'Islands' of partly ...
5
votes
1answer
141 views

ogr2ogr selecting features by attributes

I am writing a shapefile after some processing; however, in the final step I need to do some selection by attributes from the the shapefile. I am using the command in a shell with the aim of using it ...
0
votes
1answer
133 views

Why do Shapefiles and GeoJSON behave differently in GDAL Python?

I have a test.shp. I loop over the file, buffer the features, and write the buffers to a new file. I tested writing the buffers to a Shapefile and to a GeoJSON. If I try to use the new buffer layer ...
1
vote
3answers
189 views

KML to Shapefile using GDAL (LIBKML) - MultiGeometry data not transforming

I am trying to convert a KML file to Shapefile using GDAL (ogr2ogr). Regular KML files convert fine but KML files containing MultiGeometry features (eg: Geometry containing both Point and Polygon) do ...
1
vote
0answers
70 views

How to join attributes by location with command line

I would like to joint the attributes of 2 shapefiles by location but with a command line (linux). This feature is easy in QGIS but it is VERY slow. Is there a way of doing this with ogr or pyqgis ? ...
0
votes
0answers
46 views

How to use projection of a shapefile in order to have a better view in OpenGL

As you see here, this is the code that I have used to extract vertices of ESRI shapefiles in order to show them with OpenGL. I have also uploaded my project here, if you want to give it a try and see ...
1
vote
3answers
317 views

Can I have two kinds of point geometry in a shapefile or I should create multipoint shapefiles?

Following my previous question, can I have a mixture of two kinds of geometry in a shapefile of type point. Just like I have about shapefiles of type polygon or I should always create a shapefile of ...
-3
votes
1answer
70 views

How can I use ogrinfo to reach information anout a .shp?

How can I use ogrinfo? where should I write it? In the visual studio's command prompt or somewhere else? Can you make some examples? when I use ogrinfo in the windows or visual studio's command ...
0
votes
0answers
87 views

How to access vertices in a polygon layer using ogr library with c++

up to now I have tried these classes in order to extract the vertices of polygons: OGRPolygon : It doesn't have any method to get number of vertices, start point and end point. OGRLineString : ...
0
votes
0answers
110 views

How to read vector datasets using GDAL library

Up to now, I have used GDAL in order to read raster information and geotiffs and show them with the help of OpenGL. Now I have a vector dataset, and by that, I mean I have the files with types: DBF ...
1
vote
0answers
120 views

How to shift vertices of shapes in shapefile using FOSS python library?

I need to shift each vertice of shape in a shapefile (of any type:point, line, polygon, multiline etc.) with Python. I need to loop in all shapes, get the vertices, get it's coordinates and for each ...
2
votes
2answers
274 views

Python GDAL/OGR: retrieved feature is NoneType

I'm doing some scripts in Python to deal with shapefiles, and I have an issue I don't understand. I'm looping over a shapefile, and I want to retrieve the geometry of each feature, but very often I ...
0
votes
1answer
157 views

How to create feature LineString in a Polygon shape file layer (OGR/GDAL)?

I used below codes to create ShapeFile layer OGRDataSource *poDS, *poSHPDS; OGRLayer *poSHPLayer; ...... poSHPLayer = poSHPDS->CreateLayer (shpFileName, NULL, wkbPolygon , NULL); And I ...
0
votes
1answer
133 views

Problem with showing Shape file in Geoserver

I have a number of Shape files from a customer. I can read them with both ogrinfo and QGIS. They don't have a prj-file, but I know that the projection is EPSG:3006. When I add them as layers in ...
0
votes
0answers
56 views

Asking about Convert Dgn to Shp and OGRLayer::SetSpatialFilter

I used the this function: ConvertDgnToShp to convert my dgn file to shp file. But, after converting, I can't select(chose) the small polygon (that is contained in another polygon, I used ArcMap to ...
0
votes
1answer
129 views

Can't convert geometry from Dgn file to Shape file?

I am using below codes to try convert geometry from a Dgn file to Shape file. But, I can't exit the Feature reading loop. Are there anyone know why and how to fix it ? Please download the dgn file ...
5
votes
1answer
1k views

R : convert a spatial polygon objet to spatial polygon data frame

My goal is to modify an existing shapefile by merging certain polygons. After importing the shapefile and using the UnionSpatialPolygons command, I get the polygon outline that I want. However, this ...
0
votes
0answers
123 views

NYC Building Perimeter Shapefile after 2011

I've been using the following NYC building perimeter shapefile from the DOTT for some work. This file however dates back to 2010. Is there a newer one available, and if so where? I have found this ...
11
votes
1answer
422 views

How to rename field names in a shapefile from the commandline?

I need to rename the field names (attributes) in a shapefile. Is there an easy way to do this from the command line?
1
vote
4answers
260 views

Does shapefile or MapInfo TAB have advantage as source format for OGR conversion to GeoJSON?

I'm relatively new to OGR and GIS in general. Most of the sources I look at give a choice of ESRI shapefile and MapInfo formats. I'm using ogr2ogr to convert these to GeoJSON for import into ...
2
votes
1answer
217 views

OGR - Weird GeomType -2147483645 on polygon shapefile

I am trying to import a shapefile (multipolygon) in an app with ogr but I got an error about invalid geom type. If I inspect the data with ogr like this: datasource = ogr.Open("c:\\temp\\data.shp") ...
3
votes
1answer
758 views

better way to duplicate a layer using ogr in python?

I'm splitting a large shapefile into many smaller ones using ogr. I'd like to just copy all of the field and layer config information from the original. Here's how I'm doing it now: src = ...
2
votes
1answer
236 views

need help for script checking topology using ogr in python

My main goal is to create a new feature indicating if the line features intersect each other as well as if they are not connected to a feature. My problem is how to identify the intersecting and not ...
3
votes
1answer
139 views

shapefile batch clip and merge combined

I have two shapefiles, one is polyline, the other polygon. For each polygon I would like to clip the polyline vectors inside. Using arcpy I already found part of a possible solution: ...
3
votes
1answer
2k views

How do you open shapefiles with ogr2ogr

I'm following along the D3 tutorial, and on this line: ogr2ogr \ -f GeoJSON \ -where "adm0_a3 IN ('GBR', 'IRL')" \ subunits.json \ ne_10m_admin_0_map_subunits.shp run into the following ...
4
votes
2answers
297 views

How do I Capture GDAL projection and create matching output (OGR or GDAL) shape files?

Working in C++, using GDAL and OGR: Depending on what the user has supplied for image input, I need to output point (or other) shape files in the same projection as the input raster images. The ...
2
votes
1answer
277 views

How to bulk delete shapefile columns?

I have shape-file with next attribute table: - name of features, unique number for each feature of layer I must split shape-file by NAME field, but in result in attribute tables of layers should be ...
5
votes
1answer
971 views

OGR Shapefile to CSV: Using Python to get WKT for multipart Polys.

Using ogr2ogr and python, I'm running into a wall with trying to create a csv with WKTs for a shapefile that contains multipart polygons. Currently this is this code I'm using (found it on interweb): ...
3
votes
2answers
896 views

Shape-file encoding problem in QGIS 1.9.0 (built with GDAL 1.9.2)

I have googled a lot but failed to find the answer. My configuration is: Ubuntu 11.10 Quantum GIS - 1.9.0-Master 'Master' (caae7b7) GDAL 1.9.2, released 2012/10/08 Shape-files refuse to open in ...
1
vote
2answers
283 views

How to use -where SQL in an ogr2ogr loop in GDAL/OGR (bash)?

I'm using the following code: while read line; do for att in $line; do ogr2ogr -where "newcode='$att'" -f "ESRI Shapefile" $OUTPUT/$att.shp $INDATA done done < $SCRIPT/newcodes.txt The text file ...
4
votes
1answer
710 views

How to programatically populate a shapefile field with polygon areas in OGR?

I'm trying to programatically populate a shp field with polygon areas: import sys import ogr ds = ogr.Open( 'tttttttttt.shp', update = 1 ) if ds is None: print "Open failed./n" sys.exit( 1 ...
3
votes
3answers
555 views

How to merge a large amount of polygon-features in a script?

We have a very large shapefile with over 30000 features and want to merge it with a script on a server. Currently we try it with QGIS, but the processing takes way too much time. Is there a way to do ...
3
votes
1answer
198 views

Is there no EPSG code to use for Behrmann equal-area projection in ogr2ogr?

I'm trying to use ogr2ogr to reproject some shapefiles. The projection I wish to use is Behrmann equal-area. I cannot find an EPSG code to use for the '-t_srs' part of the syntax. Is there any way ...
3
votes
1answer
256 views

How to stop writeOGR from abbreviating Field Names when using “ESRI Shapefile” driver

I'm currently using the following script to add some attribute data from a table to lots of individual shapefiles: library(rgdal) specieslist <- read.csv("SpeciesList1.txt", header=F) attdata ...
1
vote
3answers
371 views

Getting Field value for a given coordinate out of ESRI Shapefile using GDAL/OGR

I have a bunch of ESRI shapefiles that contain Land Cover data across Canada (provided by Geobase). I need to query the files and obtain the value of a certain field (called COVTYPE) in a given ...
3
votes
2answers
312 views

Eliminate small polygons from shapefile

I downloaded GTOPO30 *.DEM files, and extracted a contour line at 2000m altitude using gdal_contour. In the resulting shapefile, I have many small polygons in areas where the altitude is close to that ...
9
votes
3answers
3k views

Divide a complex shape file into a grid

I have a decently detailed shapefile with polygon/multipolygon features (the file is about 500mb). It's actually a shapefile of the entire world, with the features representing coastlines. I need to ...
1
vote
0answers
273 views

ogr2ogr failed to reproject shapefile error exceeds limits

I cannot get correct transformation from WGS84 to the Hungarian EOV EPSG:23700 (Hungarian Datum 72) using ogr2ogr. I am using ogr2ogr from the fwtools shell. I have a shapefile in GCS WGS84 (epsg ...
3
votes
1answer
848 views

Convert KML to shapefile without losing attribute data

So I want to convert KML files to SHP shapefiles to load it onto PostGIS. Currently I'm using ogr2ogr to do the conversion for me, but it wipes out all the attribute data. How do i preserve this ...
10
votes
2answers
2k views

API documentation for Gdal/Ogr with C#

I want to assign projection to shapefile in my web C# application, for this i am using Gdal/OGR/OSR C# bindings and add osr_csharp.dll and ogr_csharp.dll references. But i am facing some difficulty ...
8
votes
4answers
1k views

Is there a mapping between OGR and python data types?

I'm writing a shapefile using OGR in python, creating fields on-the-fly from a python data source. Creation of a new field requires an OGR data type, is there a mapping between OGR and python data ...
4
votes
2answers
804 views

How to cut a shape file?

I want to use a shape file of the Corine Land Cover. This covers all of Europe, but I am only interested in the area of Scandinavia. How can I cut this file using free software (preferably a ...
7
votes
1answer
1k views

How to convert Shapefile geometries to WKB using OGR?

I got the geometry of a feature of the shapefile, and i want to save that geometry in the postgis (in WKB formats like it happens when we import shapefiles using shp2pgsql and psql commands). How do I ...
3
votes
1answer
271 views

Polygon Shared Boundaries in GML

Last week I was told on a phone conference that GML supports shared boundaries in Polygon's. I have been unable to find any documenatation to substantiate the claim. Here is the situation: I have a ...
20
votes
2answers
2k views

Python Efficiency — Need suggestions about how to use OGR and Shapely in more efficient way

I'm looking for some suggestions about how to make my python code more efficient. Normally efficiency doesn't matter for me but I am now working with a text file of US locations with over 1.5 million ...