help intershp

Title

intershp -- Calculate spatial intersection statistics between two Shapefiles

Syntax

intershp shpfile1 with(shpfile2) [, options]

options

crs(string) Coordinate reference system specification (required). Can be EPSG code (e.g., EPSG:3857 or 3857), TIF file path, or SHP file path

merge Merge overlapping features of shp2 before intersection calculation (deduplication)

group(string) Group statistics by specified field of shp2

Note: with() is required and must be specified before the comma. crs() is required and must be specified.

Description

intershp calculates spatial intersection statistics between two shapefiles. It computes the intersection area statistics for features in the first shapefile that intersect with features in the second shapefile specified in WITH().

Examples

Calculate intersection statistics grouped by a field:

. intershp "fuzhou.shp" with("fuzhou_building.shp"), crs(EPSG:3857) group("Floor")

Requirements

Runtime environment requirements:

• Java 17 or higher (automatically detected from Stata's Java configuration or system PATH)

• checkshp-0.1.0.jar file (JAR package needs to be built first; automatically searched in current directory, build/libs, or Stata's ado directory)

• All auxiliary files of both Shapefiles (.shx, .dbf, .prj, etc.) must be in the same directory as the main file

Technical Details

The command uses JTS (Java Topology Suite) and GeoTools libraries for spatial intersection calculations. The crs() option is required and specifies the coordinate reference system to use. The command projects both shapefiles to the specified coordinate system before performing intersection calculations.

The command uses STRtree spatial index to accelerate large-scale intersection calculations, making it efficient for processing large datasets with millions of features. Stream processing and batch merging strategies prevent memory overflow issues. The command automatically clips shp2 to shp1 bounds before intersection calculation, using spatial filtering to reduce the number of features processed, further optimizing memory usage for large shapefiles.

Author

Chunxia Chen

School of Management, Xiamen University

Email: triciachen6754@126.com

Also see

Online: checkshp, reprojshp, areashp