New answers tagged

0

This is not a bug but an expected behavior. Note that rasterize takes a fun argument that handles grid cells with two or more values. By default it uses that last function, namely the value that appears last on the data data.frame is used. Similarly first will use the value that appears first. Other functions include count, mean, etc. Here is a short ...


1

Since this is a "large" file your best bet is to style it on the server and use the WMS service to send it to your browser as a small image (i.e. a compressed png). GeoServer uses SLD to style layers, there are many examples available in the SLD cookbook which you can use as a basis for your style. In your case I would recommend using the recode function as ...


1

You can do library(raster) x <- shapefile('file.shp') crs(x) x$area_sqkm <- area(x) / 1000000 Assuming that your crs is longitude/latitude, or with meter as distance unit


2

That is a trivial task with gdal: ogr2ogr -t_srs EPSG:3857 destination.shp source.shp See http://www.gdal.org/ogr2ogr.html for more information. There might be ruby bindings for this, I have no idea. EPSG:3857 coordinates are not lat/long though, if you really need those, just use EPSG:4326.


0

In layout mode, hold ctrl+shift+b then use left-click to zoom in or out (left-click-hold+drag cursor) or right-click to pan (right-click-hold+drag cursor). It's a long reach for the fingers, but is really nice for layout adjustments.


5

In your Table of Contents (the list of layers usually found on the left side of your ArcMap window), right-click on your US border shapefile and click "Zoom to Layer". That will zoom to the extents of the layer and center your view on the layer. FYI, you can also zoom to one (or several) features in the layer, instead of the entire layer. To do that, open ...


1

If you center your map in data view, layout view should show the same extent.


1

FROM should contain table names, not column names (and 100 is missing here in the table name) The ON part should connect columns from both tables, but you have specified the same table on both sides. I suggest to put the whole sql statement in quotation marks, single ones for Linux and double for Windows. The roles of dst_datasource_name and ...


2

You need to use the -dstalpha option to gdalwarp e.g.: gdalwarp -cutline INPUT.shp -crop_to_cutline -dstalpha INPUT.tif OUTPUT.tif This will add an alpha band to the output tiff which masks out the area falling outside the cutline. P.S. duplicate question


0

It is possible to convert to shapefile in JavaScript, in the client side. The following library accomplishes this. Perhaps it is outdated (2012-2013), but at least it shows the concept. JS2Shapefile JS2Shapefile is a Javascript class to create ESRI shapefiles directly in the browser. It also includes a couple of helper classes for creating and ...


2

The simplest solution is to join the two sides together by dragging connections from each input to each output (click on the yellow arrow and drag a line from it to the equivalent red one). Then press the green run button on the toolbar and the translation will run. Quicker way to generate it in the future is to start with the empty canvas and press Ctrl+G. ...


2

To calculate overall accuracy assessment in eCognition using shapefiles you need to do following steps: First, add shapefiles in to eCognition as thematic layer by modifying the project. (make sure that points has the same projected coordinates system as your classification image) Further two steps you can find on ecognition user guide "Creating Samples ...


1

I imagine this is due to the file size limitation of Shapefiles. From "Geoprocessing considerations for shapefile output" (link): There is a 2 GB size limit for any shapefile component file, which translates to a maximum of roughly 70 million point features. The actual number of line or polygon features you can store in a shapefile depends on the ...


2

In the spirit of your question, I too would use GeoPandas like gene said. However I'll also directly answer your question how to do this in matplotlib... Create an object to map continuous values to colors. ScalarMappable is the matplotlib class to do this, and you can give it a Normalize behavior to anchor the min and max range of the values you want to ...


2

The simple way is to use GeoPandas import geopandas as gpd # read the shapefile as a GeoDataFrame can = gpd.GeoDataFrame.from_file("CAN_adm1.shp") # The first element can.head(5) ### many data #plot the shapefile/GeoDataFrame can.plot() You can even plot a column can.plot(column='NAME_1');


3

The polygon is not "wrong", it's just not representing landmass It uses 1 polygon for each province. You can find polygons representing Canada's borders and land surface on GADM or DIVA-GIS


3

You could create a Custom function in the Function Editor to use the python ORD() function to get the ASCII value of a character (A being 65): http://www.qgistutorials.com/en/docs/custom_python_functions.html The function might look like this: from qgis.core import * from qgis.gui import * @qgsfunction(args=0, group='Custom') def ord_place(value1, ...


1

In your Field Calculator interface, go to the Function Editor tab, create a new file and input the following code: from qgis.utils import qgsfunction from qgis.core import QgsExpression, QgsMapLayerRegistry @qgsfunction(args="auto", group='Custom') def stringtoNum(field, feature, parent): val = dict(zip(string.letters,[ord(c)%32 for c in string.letters]...


3

Right-click on your layer in the Layers Panel and then click on Open the Attribute table. Click on Open field calculator (CTRL+I). There, create a new (virtual) field with the following expression: CASE WHEN col1 = 'A' THEN 1 WHEN col1 = 'B' THEN 2 WHEN col1 = 'C' THEN 3 ELSE 0 END Edit: you can also use strpos to return the position of ...


1

If you want to preserve the names of your rasters, consider saving your shapefile as a feature class in a geodatabase . See here for feature class field name limits.


0

I agree @anoved Refer these two articles on reading the shapefile and using opengl to render. http://www.codeproject.com/Articles/32035/Rendering-Shapefile-in-OpenGL http://www.codeproject.com/Tips/1021362/Rendering-Shapefile-in-OpenGL Per suggestion from @Simbamangu, including excerpts from the source code.There are two main activities in achieving the ...


1

This process worked for me: http://ssrebelious.blogspot.co.uk/2012/09/raster-extent-modification-using-qgis.html "In QGIS you can change extent of the rasters. Lets examine one of the worst case scenarios. There are two overlapping (one band) rasters A and B. Say, we need to add A values to B values and get the final image to have extent that will contain ...


1

I figured this out. It seems like there were some artifact functions with the name addGeometryColumn (overloading in postgres is possible). This error in the logfile made me suspect there is something very wrong with the addGeometryColumn function: ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) is not unique at ...


1

If you want to interact with this data using SQL expressions without loading into a database server (PostgreSQL/PostGIS or SQL Server), try loading the shapefiles into QGIS and use the DB manager plugin. There is a node called "Virtual Layers" > "QGIS Layers" then you will see the shapefiles in your map. You can hit the "SQL Window" button and start writing ...


2

You can install PostgreSQL (opensource) and the PostGIS and TIGER extensions to load the TIGER data. This post has a lot of good info that I used to load the census data. Then you can run SQL queries to get at the data. I loaded all US Data into PostgreSQL on a Win 7 (64 bit) with 8 GB ram and a 230 GB hard-drive (with other apps installed).... I am just ...


0

I would do a dissolve on the shape file so that the shape file only contains a single entry based on country you can them label as required


-1

I have seen the same problem. In my case the raster and the clip vector are both in the same space so there is no need for a transformation. It worked with earlier versions of GDAL so I suggest regressing to 2.02 and it will work.


2

The XML document with a .shp file type is the metadata behind the shapefile. From what it appears, you do not have all the prerequisite files for a shapefile.


2

May be you can change the styles in your published layers. layer(Menu on the left)---> select you published layers--->select publish --->Default Style--->change to polygon


0

Specifically answering the question you could use osm2pgsql to get the open street map into postgres. From here you can use postgres to shape command line pgsql2shp Bare in mind - TileMill is going to generate a rastered image map tile / not a vector. Using the original protocol buffer format / pbf is a better place to start and then you can apply ...


0

After the simple and understandable answer, I came up myself with a straightforward way to plot a whole shp with matplotlib. I feel geopandas should just update their plotting function because this one is simple but so much faster including the full flexibility of matplotlib - adding legend, title, etc. from descartes import PolygonPatch import geopandas as ...


2

There is a Python module for that: Descartes (look at Plot shapefile with matplotlib for example) from geopandas import GeoDataFrame test = GeoDataFrame.from_file('poly1.shp') test.set_index('id', inplace=True) test.sort() test['geometry'] testid 0 POLYGON ((1105874.411110075 -6125459.381061088... 1 POLYGON ((1106076.359169902 -6125875.557806003... 2 ...


0

Document for loading geospatial data into dashDB is at https://www.ibm.com/support/knowledgecenter/SS6NHC/com.ibm.swg.im.dashdb.doc/learn_how/loaddata_gsdata.html The source file must be a compressed file in one of the following formats: tar.gz tar zip This file must include a shapefile set that contains the following files: [.shp .shx .dbf ....


0

For updating with a shapefile, you need to convert the shapefile to raster then use some map algebra in order to do the computation. The conversion from shapefile to raster is done in any case, even if it is sometimes "hidden" by some tool. for speeding up the process with ArcGIS, you could divide your huge image in small tiles and process only the tiles ...


2

a) With the solution you use (Pyshp (shapefile), you need 1) to extract the fields of the csv file 2) to define the fields of the shapefile (w.field('Target','C',50)) 3) to construct the geometry from the lon et lat fields ( w.point(float(i['x']),float(i['y'])) (see CSV to Shapefile ) b) With Fiona, it is easier but you have the same problem of field ...


0

Try this: import os import sys import fnmatch dirToProcess = sys.argv[1] matchPattern = sys.argv[2] replacePattern = sys.argv[3] print "Processing " + dirToProcess if (os.path.isdir(dirToProcess)): print "dir " + dirToProcess + " found" else: print dirToProcess + " not found" exit () print "continuing processing..." for filename in os....


3

Use the walk function from the data access module and Rename tool from Data management. Refer to the help files for code samples


1

I answer this assuming you'll be using rgdal to read the shapefile in as a spatial dataframe. Instead of worrying about cutting, you can make a join using the tigris package. You can use the function geo_join() to combine a spatial dataframe and a dataframe. To only include the subset of postal codes from the dataset, set the "how" option to "inner" to get ...


0

Install PostgreSQL (an open source database) and spatially enable it with PostGIS (which comes with a tool to convert shp files into the database). Then you can run the function 'st_within' to see if the location falls within a logical area.


3

Please update to a later version of 2.14.x (currently we are at 2.14.3), this issue has already been fixed.


4

As in my comment, simply rename the .dbf file, so it will not be recognised as part of the shapefile, and therefore will not be loaded.


1

As a first guess, you can create a custom transverse mercator projection on one of you coresponding points. Preferably the one closest to the DXF origin: +proj=tmerc +lat_0=41.045452 +lon_0=28.895929 +k=1 +x_0=1.03521 +y_0=-6.34918 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs lon_0 and lat_0 are the degree coordinates in WGS84, and x_0 and y_0 ...


2

You will first need to geo-reference the data in the DXF. If it has been drawn at 0,0 it is not in real world co-ordinates so trying to re-project will do nothing. If you know where the data should be in UTM (or some other projection) you can move it in AutoCAD to the correct location, then re-save and import back into QGIS. Then you will be able to convert ...


2

Have a look at How to georeference a vector layer with control points?, in particular the answer concerning the Vector Bender plugin for QGIS. Watch the video and try the plugin, report back if you encounter any issues.


2

Yes, editing shapefiles is a very common task for any GIS, including QGIS. While Esri developed the shapefile, it is an open standard that can be used by nearly every GIS platforms. The editing tools are in the "digitizing" toolbar. The pencil button starts an editing session. From there you can edit the attributes of a feature, or the vector geometry. I ...


1

I think you have to carry out three transformations, wich are all affine transformations: scale, rotate and translate. I suggest reading about affine transformation on wikipedia: https://en.wikipedia.org/wiki/Affine_transformation If you basically can carry out an affine transformation, then this might help you to determine the correct parameters: http://...


1

Got it! An environment variable needs to be set. It can be set either in the shell: export SHAPE_ENCODING="utf-8" or within the script: os.environ['SHAPE_ENCODING'] = "utf-8" I prefer to set it in the script. I tried out various ways of decoding from utf-8 and encoding to ISO8859_1 within the script with no luck. feature.SetField does not accept ...


1

If this is the only map that you want to process,then the easiest way to convert this raster into polygon in a clean way is to digitize it, since the map that you are showing is not complex map. Create a new field of "population density" and fill in the values based on the information in the legend. If you have an administrative boundary for this shapefile ...


1

Your Insert Cursor field list is adding attributes only. You need to include SHAPE@XY in your field list, and pass the XCoord and YCoord info to them: cursor1 = arcpy.da.InsertCursor(out_shp,["SHAPE@XY", "XCoord", "YCoord", "STATE_NAME", "NAME", "totpop", "POLY_ID", "OBJECTID", "STATE_FIPS", "CNTY_FIPS", "FIPS", "FIPSnum","FIPS_NUMER","area1"]) cursor1....


0

The easiest way to check for data in a shapefile if you don't have GIS software handy is to open the shapefile's DBF file with Excel. For example, I have created a shapefile and added a field to it, but created no features. In the Excel Open dialogue you need to change the Type drop-down to dBase File And the file open in Excel shows a couple of field ...



Top 50 recent answers are included