New answers tagged

1 vote

Seeking Italy building shapefile

The GlobalMLBuildingFootprints dataset by Microsoft https://github.com/microsoft/GlobalMLBuildingFootprints covers also Italy as can be seen from the index map https://github.com/microsoft/...
user avatar
  • 51.5k
0 votes

'union' between spatial polygons and spatial points in R

I found out how to do it. Two ways: applying point.in.poly(grid, acled). So x= polygons, y=points. applying point.in.poly(ACLED, grid) in the right way then merging with the initial grid. grid....
user avatar
  • 31
2 votes

Seeking Italy building shapefile

You can download it from OpenStreetMap. Go to https://OpenStreetMap.org zoom to area where you want to download the openstreetmap data. This data includes all data including roads, buildings etc. You ...
user avatar
  • 491
0 votes

Split TIFF and shapefile into smaller parts

This is my first project with geo data and for some reason I thought if I split the tif I must do the shape at the same time, so there should be a command to do just that. My solution: Created a grid ...
user avatar
1 vote

Artificially extend a DEM to clip it

I found a way to do it on Python: (PS: I USED A DIFFERENT DEM FOR THE EXAMPLE, TO DEMONSTRATE HOW TO DEAL WITH BORDERS) # Open the DEM and extract all the info about it src = rio.open('IfSAR_merged....
user avatar
  • 107
2 votes
Accepted

Opening shapefile in ArcGIS Desktop

Your file are not a "project" but just some data in shapefile format (all these file with the same name but different extension are what is called a shapefile, for more information on what ...
user avatar
  • 11.8k
1 vote

Extracting admin boundary data from OpenStreetMap

It depends how many boundaries you would like to extract from OSM. For single city shape osmnx would be easiest option. If you need to get admin boundaries for whole country, processing OSM data dump ...
user avatar
1 vote

GeoPandas input file to shapefile with coordinate system information

Set the CRS when you create the GeoDataframe: gdf = gpd.GeoDataFrame(df, geometry=etc..., crs="the CRS of your xy coordinates") Note, this requires you know the CRS your coordinates are in ...
user avatar
  • 51.7k
2 votes

Deleting lines automatically which are not connected in QGIS

Another approach is to use the "Extract by expression" tool with an expression that contains the overlay_touches() function: overlay_touches(@layer) Before: After:
user avatar
  • 22.7k
1 vote

Deleting lines automatically which are not connected in QGIS

An alternate method is to use the "Service area" tools in QGIS. You can use this tool with a really long distance to find what is connected to the main network Then use that to select the ...
user avatar
0 votes

Last record of a shapefile not visible on the map

A similar bug is discussed here: Shapefile stopped displaying polygons and gives error: 'No extent could be determined' in QGIS 3.10 It seems like the bug should be fixed in the newest QGIS ...
user avatar
2 votes

Implement plot purchases on fictional map

Here's a workflow using QGIS and some data from the Leaflet examples. Before you start, read the Leaflet tutorial about L.CRS.Simple. I mean it. Stop what you're doing, and read it. Lauch QGIS. Read ...
user avatar
  • 9,285
5 votes

Selecting points which touch "boundaries" of another polygon using QGIS

You can use "Select by expression" via QGIS's Processing Toolbox (Ctrl+Alt+T) or attribute table (F6). Run it on your points layer and use this expression: distance( $geometry, ...
user avatar
  • 24.6k
4 votes

Selecting points which touch "boundaries" of another polygon using QGIS

Convert your polygons to lines Select by location, the buffers intersecting the lines (or Select within distance, your title says points but question body says polygons)
user avatar
  • 51.2k
1 vote

Converting x/y in Pandas DataFrame to lat/long

Firstly I recommend the os.path.splitext() function from the os.path module to get file_extension and output_file in a bit more elegant way: from os.path import splitext input_file = '.../input_file....
user avatar
  • 22.7k
1 vote

ShapefileException when reading shapefile using PyShp

I could also get the ShapefileException when: the path to a shapefile is wrong the shapefile's name was wrongly specified there is no permission to access the shapefile First of all, I suggest to ...
user avatar
  • 22.7k
2 votes

CRS is empty but GeoDataFrame plotted correctly when reading shapefile with GeoPandas

The shapefile is a bundle of files. One of them is the .prj. When reading a shapefile with GeoPandas and either: .prj is an empty file no .prj file at all the output will be None. So, in this case, ...
user avatar
  • 22.7k
1 vote

Feature creation error (OGR error: Coordinates with non-finite values are not allowed)

I had the same problem. Unfortunately, JanaB's solution didn't work for me, as I couldn't right click on some vertices in my shapefile. I was about to make a bug report when I found this: "Did ...
user avatar
1 vote
Accepted

Delete a shapefile feature without mixing up the feature IDs?

Shapefiles (being an old and obsolete format) don't have a dedicated feature id, they just use the row number so a delete will change (some) of the ids when you close and reopen them.
user avatar
  • 74.6k
1 vote

QGIS Aggregate 1x1km grid into 10x10km for Brazilian Land-Use Data

Step 1. Create a bigger grid 10*10 km using the "Create grid" tool with the following setting: Grid type : 2 — Rectangle (polygon) Grid extent : Calculate from layer : 1x1km grid of the ...
user avatar
  • 22.7k
1 vote

Merging multiple point layers with common fields to create single table in QGIS

There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Let's assume there are two point layers one called 'points1' and second called '...
user avatar
  • 22.7k
6 votes
Accepted

Getting all shapefile layers in project using PyQGIS

The shapefile format is a geospatial vector data format, therefore on a first stage I suggest to catch all of vector layers with the QgsVectorLayer class. There are several approaches to achieve it ...
user avatar
  • 22.7k
1 vote

Merging multiple point layers with common fields to create single table in QGIS

Menu Processing > Toolbox > Merge Vector Layers. Field calculator: create a new string (text) field with this expression: concatenate( to_string(unique_value1), concatenator:=',', group_by:=...
user avatar
  • 40k
0 votes

Merging Linestrings to bigger Linestrings

I don't know if this could be useful for you. I wrote a script to create the longest paths from a layer of lines, it doesn't split lines, it only joins the beginning and end of the lines. Maybe it ...
user avatar
  • 66
0 votes

R lm.LMtests error in lag.listw(listw, y, zero.policy) : y not numeric

Changing the dependent variable's class from character to numeric resolved the problem. fires_OGR$FIRE = as.numeric(fires_OGR$FIRE)
user avatar
1 vote

R Distance from Point to Line: Negative if within shape

Outine solution: Cast the polygons to lines using st_cast and compute distances of pounts to lines (otherwise you get zero for the distance of points inside polygons). Use st_intersects on the ...
user avatar
  • 51.1k
1 vote

Python: Open a (line) shapefile and calculate distance to point given as a longitude-latitude tuple

Python packages have matured a lot since this question was asked. Here is a complete solution. import pandas as pd import geopandas as gpd # The 2021 Hurricane Ida 2021 track line. From here: # ...
user avatar
  • 865
2 votes

Read shapefile into pysal

Whith Pysal or libpysal you don't need geopandas to read a point shapefile import libpysal from pointpats import PointPattern shp = libpysal.io.open('point.shp') pp = PointPattern((pt[0],pt[1]) for ...
user avatar
  • 50.7k
1 vote

Read shapefile into pysal

You can use geopandas import geopandas as gpd from pointpats import PointPattern gdf = gpd.read_file('points.shp') pp = PointPattern([[p.x, p.y] for p in gdf.geometry])
user avatar
  • 51.7k
2 votes
Accepted

Looking for Python equivalent of QGIS "Nearest Neighbour analysis" tool

This attempt is not finished yet, because it requires Ellipsoidal distance instead of Cartesian. As you can see in the source code spatialIndex = QgsSpatialIndex(source, feedback) distance = ...
user avatar
  • 22.7k
0 votes

Looking for Python equivalent of QGIS "Nearest Neighbour analysis" tool

You can call the same tool directly from python arguments = { "INPUT": layer, "OUTPUT_HTML_FILE": "path/to/html.html" } output = processing.run("qgis:...
user avatar
2 votes

Importing text file with coordinates with "N12.345" and "E6.789" as shapefile in QGIS

Here is another approach. Step 1. Drag&Drop your .xlsx file with all tables into QGIS, So, they all will be visible in the Layers Panel Step 2. Use a "Virtual Layer" through Layer > ...
user avatar
  • 22.7k
1 vote
Accepted

Census Block Group shapefile and demographic data confusion

The U.S. Census Bureau updates their enumeration geographies (blocks, block groups, tracts) for each decennial census. If you are using 2020 census data or 2020 American Community Survey (ACS) data, ...
user avatar
  • 8,020
6 votes
Accepted

Anonymize site locations

There's a function in the maptools package called elide that is designed to shift and rotate spatial data. It can also flip, reflect, and rotate vector data, but it might be hard to do the equivalent ...
user avatar
  • 51.1k
2 votes

Creating CSV with lat/long from point shapefile using Python

Another solution involves the PyShp package and some Python standard libraries: csv and os. Let's assume there is a point layer called 'points' with 10 features in it, see the image below. Apply the ...
user avatar
  • 22.7k
8 votes
Accepted

Creating CSV with lat/long from point shapefile using Python

Use GeoPandas to solve your problem. import geopandas as gpd 1. Load Spatial Data gdf = gpd.read_file(shp_file_path) When you load spatial data using geopandas, you can view the geometry with ...
user avatar
  • 578
1 vote

ogrinfo - specify what information you want returned

The ogr2ogr utility is a general purpose tool and all that it can do is documented in https://gdal.org/programs/ogrinfo.html. There are some options for limiting the amount of output (-nocount -...
user avatar
  • 51.5k
1 vote

Creating route shapefile based on start and end mile markers in ArcMap

The best approach for this did turn out to be the "Make Route Event Layer" tool as suggested by Hornbydd. My biggest issue was actually due to a couple blank spaces on my ROUTE_ID field ...
user avatar
  • 11
0 votes

Save certain ogrinfo results to variable in Python

The simplest but potentially most manual way is just to index the output: layer_name = stdout[12:25]
user avatar
3 votes
Accepted

Converting XYZ file to shapefile using Python

I have numerous XYZ files, which aren't gridded from GDAL XYZ – ASCII Gridded XYZ GDAL supports reading and writing ASCII gridded XYZ raster datasets (i.e. ungridded XYZ, LIDAR XYZ etc. must be ...
user avatar
  • 50.7k
0 votes

Converting XYZ file to shapefile using Python

I'm not sure but it seems to me that but in Qgis Processing / SAGA, the command 'import feature from XYZ' allows to generate shp
user avatar
  • 599
3 votes
Accepted

Deleting feature from Costa Rica shapefile using ArcMap

Sounds like the problem is that it's a part in a multi-part feature? You can confirm this by using the select tool and manually selecting it, if other parts of Costa Rica become selected then you know ...
user avatar
  • 38.4k
0 votes

Deleting feature from Costa Rica shapefile using ArcMap

Select all features except Costa Rica, and export the selected feature into a new shapefile.
user avatar
  • 612
0 votes

Deleting feature from Costa Rica shapefile using ArcMap

Open an editing session and delete the vertices that make up the island.
user avatar
  • 1,933
0 votes

Merging Linestrings to bigger Linestrings

For doing this kind of thing in Python I would recommend looking into the Shapely library, where the linemerge command will combine chains of contiguous LineStrings into larger LineStrings. If you ...
user avatar
  • 221

Top 50 recent answers are included