7
votes
Accepted
sf equivalent of R maptools package's SpatialLinesMidPoints
Looks like maptools:::getMidpoint, which underpins maptools::SpatialLinesMidPoints, can be applied to a LINESTRING geometry set without too much modification, e.g.
st_line_midpoints <- function(...
6
votes
Accepted
Bind polygon centroid to polygon attribute data
Load libraries and example data
# Load libraries
library('raster')
library('geosphere')
library('mapview') # incredible interactive map visualization in R
# Get SpatialPolygonsDataFrame object ...
5
votes
Accepted
PyQGIS/QGIS2.18 : Get currently active map tool
One issue with trying to get the name of the tool is that not all tools have a name to begin with. For example, when using the Select Feature(s) tool, it's tool name is:
iface.mapCanvas().mapTool()....
4
votes
Accepted
Wait for user selection from user interface
It's difficult to tell exactly without the full code, but I noticed you're calling
self.selectionList_dlg.show()
I suspect this should be
self.selectionList_dlg.exec_()
As exec_ will wait till ...
4
votes
Plotting shapefile in R: how to delete selected borders?
E.g. with gUnaryUnion from the rgeos package:
library("rgeos")
plot(gUnaryUnion(xx), col = "red", axes = TRUE)
plot(gUnaryUnion(xx[c(9, 31, 82), ]), col = "blue", add = TRUE)
4
votes
Accepted
How to create a map tool with QgsMapToolEmitPoint that has snapping functionality?
You need to sub-class QgsMapToolEmitPoint instead of using the default implementation. Here is a basic example:
class CustomMapTool(QgsMapToolEmitPoint):
def __init__(self, canvas):
self....
4
votes
Accepted
PyQGIS how to not select objects that are hidden by a layer style?
Here is a solution based on this answer by Yoann Quenach de Quivillic.
You can add this function:
def get_visible_selected_features(self):
renderer = self.layer.renderer().clone()
ctx = ...
3
votes
Accepted
crop wrld_simpl gives error after R update
This is because of changes in the rgeos package. The problem appears to go away if you do as the error message says: consider using set_RGEOS_CheckValidity(2L)
library(raster)
library(maptools)
data(&...
2
votes
simple plotting of (latitude, longitude) points on a global map
Sample code.
Given a world map (e.g. lat: 80 ~ -80, lon: -160 ~ 160) was downloaded as PNG ("Downloaded_Image.png").
library(png)
Downloaded_Image <- readPNG("Downloaded_Image.png")
library(...
1
vote
Accepted
Colouring wrld_simpl countries with a variable
Its using the integer value behind the factor for the colouring, and then getting the colour from the current palette.
Convert the factor to character if you want to use a factor column's levels as ...
1
vote
Accepted
How to remove outliers from spatial polygon
First to the issue of your data. As hinted at by @Dataform in the comments, it appears that the Jung district of Busan has accidentally been coupled with the Jung district of Incheon in the GADM data.
...
1
vote
Accepted
Error in converting shapefiles into spatstat window
library(rgeos) #required by maptools
library(maptools)
library(spatstat)
sca <- readShapeSpatial("KOR_adm1.shp") #upload Korean provinces
sca <- sca[sca@data$NAME_1 %in% c("Seoul", "Incheon", "...
1
vote
Accepted
Mapping data: error in classIntervals: var is not numeric
You've done this:
breaks <- classIntervals(EU_NUTS@data$X2012._Y20.64_T,
n = 5, style = "fisher", unique = TRUE)$brks
which is trying to get a column called "X2012._Y20.64_T". Does that ...
1
vote
Accepted
Kernel Density Map points rejected as outside window
The best explanation I could suggest looking into is similar to this response I found in a different forum, Warning message: points were rejected as lying outside the specified window.
These points ...
1
vote
Merging multiple SpatialPolygonDataFrames into 1 SPDF in R?
library(sp)
data(meuse)
plot(meuse)
slotNames(meuse) #".Data" "names" "row.names" ".S3Class"
coordinates(meuse) <- ~x+y #Add "ID" column to "meuse"
slotNames(meuse) #[1] "data" "...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
maptools × 35r × 26
pyqgis × 5
sp × 5
qgis × 4
shapefile × 4
raster × 3
coordinate-system × 3
polygon × 3
rgdal × 3
ggplot2 × 3
spatstat × 3
qgis-plugins × 2
google-maps × 2
merge × 2
sf × 2
snapping × 2
maps × 2
rgeos × 2
ggmap × 2
arcgis-desktop × 1
python × 1
arcmap × 1
qgis-3 × 1
data × 1