38

Here is an example using a SpatialGrid object: ### read shapefile library("rgdal") shp <- readOGR("nybb_13a", "nybb") proj4string(shp) # units us-ft # [1] "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 # +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83 # +units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0" ### define ...


28

Previous answer gives correct result, but I allowed myself to improve the code, to avoid many unnecessary lines, as well as iterating on indexes instead of values on the list. import geopandas as gpd from shapely.geometry import Polygon import numpy as np points = gpd.read_file('points.shp') xmin, ymin, xmax, ymax = points.total_bounds length = 1000 wide = ...


26

Look at the Processing Toolbox and you may choose many algorithms without the need of a plugin


24

I assume you want your irregular point data on a regular raster. In that case, rasterize should work, and the examples in ?rasterize show how. Here is something based on your data s100 <- matrix(c(267573.9, 2633781, 213.29545, 262224.4, 2633781, 69.78261, 263742.7, 2633781, 51.21951, 259328.4, 2633781, 301.98413, 264109.8, 2633781, 141.72414, 255094.8, ...


23

You don't need a plugin, just use a geoalgorithm from the toolbox: Vector > Research Tools > Create Grid... In QGIS 2.10 this is called 'Create Graticule'


23

There are many solutions. One of them import geopandas as gpd from shapely.geometry import Polygon import numpy as np points = gpd.read_file('points.shp') xmin,ymin,xmax,ymax = points.total_bounds width = 2000 height = 1000 rows = int(np.ceil((ymax-ymin) / height)) cols = int(np.ceil((xmax-xmin) / width)) XleftOrigin = xmin XrightOrigin = ...


19

You can create a regular grid simply by vectorising an empty raster: SELECT (ST_PixelAsPolygons(ST_AddBand(ST_MakeEmptyRaster(100, 100, 1.1, 1.1, 1.0), '8BSI'::text, 1, 0), 1, false)).geom


15

here is an example. You need to extract the bounding box from a describe object. desc = arcpy.Describe(fc) arcpy.CreateFishnet_management(fc[:-4]+"_c200.shp",str(desc.extent.lowerLeft),str(desc.extent.XMin) + " " + str(desc.extent.YMax + 10),"200","200","0","0",str(desc.extent.upperRight),"NO_LABELS","#","POLYGON")


15

here is a solution using sf and sf::st_make_grid: library(raster) library(sf) e <- as(raster::extent(-125, -65, 25, 49), "SpatialPolygons") %>% st_as_sf() grd_lrg <- st_make_grid(e, cellsize = c(5, 2)) %>% st_set_crs(4326) %>% st_transform(5070) plot(grd_lrg)


13

The New York dataset provided in the question is no longer available for download. I use the nc dataset from sf package to demonstrate a solution using sf package: library(sf) library(ggplot2) # read nc polygon data and transform to UTM nc <- st_read(system.file('shape/nc.shp', package = 'sf')) %>% st_transform(32617) # random sample of 5 points ...


13

The following script will do the job with GDAL and Python: import os, sys import ogr from math import ceil def main(outputGridfn,xmin,xmax,ymin,ymax,gridHeight,gridWidth): # convert sys.argv to float xmin = float(xmin) xmax = float(xmax) ymin = float(ymin) ymax = float(ymax) gridWidth = float(gridWidth) gridHeight = float(...


12

Vector grid creation has been incorporated in QGIS for a long time: Vector -> Research Tools -> Vector Grid Note that the default grid spacing of 0.0001000000 units of the layer CRS is too small in most cases. You might want to use Vector -> Geometry Tools -> Densify Geometries afterwards if you need to reproject the grid to another CRS where ...


12

This answer was given to the original question prior the edit: Here is a graphical model you can use: So basically, you first need to create your parent grid as rectangles and order them with an SQL statement, that allows to order by X asc and Y desc: select *, ROW_NUMBER() OVER(ORDER BY ST_MinY(geometry) desc, ST_MinX(geometry) asc) as id FROM input1 (see ...


11

You need to use Split Vector Layer from processing toolbox. You can find the tool from Processing toolbox -> QGIS geoalgorithms -> Vector general tools -> Split Vector Layer Select the input shapefile and use a unique ID field to save each grid block into separate file. You need to specify the output folder to save all the polygons in it.


10

You can create a new layer with the re-ordered ID Run the grid tool as you currently do. Go the the menu layer / add layer / add-edit virtual layer and enter the following query. select *, ROW_NUMBER() OVER(ORDER BY ST_MinY(geometry) asc, ST_MinX(geometry) asc) as newID FROM Grid you can replace the layer name (Grid) with the true name. If you don't ...


10

You use wrong TYPE code. You have to use 2 for rectangular grid. 3 means diamond. params = {'TYPE':2, ...} # 2: rectangle For more details about the algorithm try import processing processing.algorithmHelp("qgis:creategrid") and get more info: Create grid (native:creategrid) This algorithm creates a vector layer with a grid covering a given ...


10

You can use GRASS v.mkgrid tool in Processing Toolbox > GRASS > Vector.


9

I've created a variant of @Alexander's function that doesn't require that we transform to another SRID. This avoids the issue of having to find a projection that uses meters as units for a particular region. It uses ST_Project to properly stride using the given projection. I've also added a width_step and height_step to allow for rectangular tiles instead ...


9

Create a polygon grid using the Vector Grid tool instead of lines. Make sure to check the polygon output. Once you have a polygon grid (also known as fishnet), you can use the Sum line length tool in the QGIS Vector analysis tools. This will result in a new field for each cell with the total road length inside it Here's a simple example of a vector ...


9

You can do this with both the Create Fishnet tool or the Grid Index Features tool. Create Fishnet is a bit more configurable, and can output either polygon or polyline. Both will allow you to set a width and height.


9

Instead of looking for the Create Fishnet (or any other) tool in ArcToolbox, I recommend using the Search window to search for and open it. If you are curious to know which toolset it is located in for the ArcGIS version that you are using then after searching for it you can click on the green link returned.


9

You can make a long/lat raster and transform library(raster) r <- raster(ext = extent(-125, -65, 25, 49), res=c(5,2)) values(r) <- 1:ncell(r) rA <- projectRaster(r, crs="+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m") But what you want seems to be library(rgdal) p <- rasterToPolygons(r) # or do: p ...


9

You have two options here. First one will create a new vector layer with a grid and the second one will just display a grid as overlay. What you are looking for is the first option. However, in case someone else is finding this question, the second option might be helpful as well. Edit: of course 10m xy, not 100m as said below... First option: Run "Create ...


8

This Python script uses the pyshp library, as suggested by user16044: import shapefile as shp import math minx,maxx,miny,maxy = 448262.080078, 450360.750122, 6262492.020081, 6262938.950073 dx = 100 dy = 100 nx = int(math.ceil(abs(maxx - minx)/dx)) ny = int(math.ceil(abs(maxy - miny)/dy)) w = shp.Writer(shp.POLYGON) w.autoBalance = 1 w.field("ID") id=0 ...


8

Here is an optimized and efficient algorithm to create fishnet, regular grid, polygon grid, rectangular grid inside any envelope, polygon, or multipolygons. almost handle any SRID; GitHub Repo: https://github.com/imran-5/Postgis-Custom DROP FUNCTION IF EXISTS PUBLIC.I_Grid_Regular(geometry, float8, float8); CREATE OR REPLACE FUNCTION PUBLIC....


8

The ogr2ogr clip operation creates polygons but for some reason also linestrings to to South and East edges of the area. Pink lines below show those 100 linestings (one is selected). Because of mixed geometrytypes the result cannot be saved into shapefile and therefore the error. I am not sure if this is an intended behaviour of ogr2ogr clipping or a bug. ...


8

As Vince said, the Create Fishnet tool is what you want to use. At the top of that help page in the summary section is a link to the How Create Fishnet Works page. Note that the main help page for most tools has a chart outlining various parameters, but many of them have such a 'how it works' link the same place that explains in more detail, often with ...


8

This way it should work: Reproject your points to a projected CRS with metres as units (if not already done) Draw buffers with a radius of 50m (half of the grid size) around them with Vector -> Geoprocessing Tools -> buffer(s) Create the vector grid with the extent of the buffer layer and 100m spacing


8

You can use the floor function in your expression, like this: floor($id /24) IN (1,3,5,7,9,11,13,15,17,19,21) On a sample grid I've obtained this result with my own numbers (my grid has 13 columns per row): I've used: floor($id/13) IN (1,3,5,7,9) So, in general: floor($id / number_of_columns) IN (1, 3, 5, ..., 2*number_of_rows_to_be_selected - 1) To ...


8

This is a bit of a workaround in QGIS 3.8 and requires that the points are separated by a uniform distance (bit it looks like it from your screenshots). Create a grid with the same spacing and dimensions as your points - somewhere in the vicinity with Processing Toolbox --> Create grid Next, enable the editing mode on the new Grid grid. Make sure that the ...


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