Skip to content

Instantly share code, notes, and snippets.

View iamgeoknight's full-sized avatar

Spatial Dev Guru iamgeoknight

View GitHub Profile
onGeomChange = (e) => {
/*
This function will dynamically split the polygon into two parts by a line and will follow geometry change event.
*/
//Create jsts parser to read openlayers geometry
let parser = new jsts.io.OL3Parser();
//Creating line geometry from draw intraction
let linestring = new ol.Feature({
@iamgeoknight
iamgeoknight / ogr2ogr.ipynb
Last active December 4, 2021 13:58
ogr2ogr Introduction
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamgeoknight
iamgeoknight / shp_import.py
Last active October 30, 2021 16:40
Shapefile Import using GeoPandas
from sqlalchemy import create_engine
import geopandas as gpd
user = "postgres"
password = "admin"
host = "localhost"
port = 5432
database = "postgis_in_action"
conn = f"postgresql://{user}:{password}@{host}:{port}/{database}"
@iamgeoknight
iamgeoknight / zindex.js
Created September 18, 2021 13:38
Layer's ZIndex in OpenLayers
let map = new ol.Map({
target: map_div,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat(center),
zoom: zoom
@iamgeoknight
iamgeoknight / geometry_Events.js
Last active September 12, 2021 13:23
Creating a Geometry Event Listener
let draw = new ol.interaction.Draw({
type: "LineString"
});
//Create interaction listener for draw
draw.on('drawstart', function (e) {
//Perform Task on when interaction starts
});
draw.on('drawend', function (e) {
@iamgeoknight
iamgeoknight / map_events.js
Created September 12, 2021 12:51
Creating a Map Click Event Listener
let map = new ol.Map({
target: map_div,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
wmsLayer
],
view: new ol.View({
center: ol.proj.fromLonLat(center),
//Create map and vector layer
let map = new OLMap('map', 1, [-96.6345990807462, 32.81890764151014]).map;
//Feature Information on Map Click
map.on('singleclick', function (e) {
let url = wmsLayer.getSource().getFeatureInfoUrl(
e.coordinate,
map.getView().getResolution(),
@iamgeoknight
iamgeoknight / feature_info_1.js
Last active September 10, 2021 16:06
Code for creating layer, Map and Popup
//Create a wms layer
let wmsLayer = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {'LAYERS': 'ne:ne', 'TILED': true}
})
});
/*
Create and Render map on div with zoom and center
let mergePolygon = (e) => {
/*
This function is applicable to merge only two polygons
This function will merge or perform union on two adjacent polygons. For the merge function to work, the polygons should atleast intersect each other.
*/
//Create jsts parser to read openlayers geometry
let parser = new jsts.io.OL3Parser();
//Parse Polygons geometry to jsts type
@iamgeoknight
iamgeoknight / polygon_split.js
Last active February 28, 2024 13:16
Split Polygon by Line
onGeomChange = (e) => {
/*
This function will dynamically split the polygon into two parts by a line and will follow geometry change event.
*/
//Create jsts parser to read openlayers geometry
let parser = new jsts.io.OL3Parser();
//Creating line geometry from draw intraction
let linestring = new ol.Feature({