Skip to content

AI gen code to allow negative buffers#295

Open
balbionthebox wants to merge 1 commit intodevelopfrom
feature/negative_buffers
Open

AI gen code to allow negative buffers#295
balbionthebox wants to merge 1 commit intodevelopfrom
feature/negative_buffers

Conversation

@balbionthebox
Copy link
Copy Markdown
Member

@balbionthebox balbionthebox commented Mar 4, 2026

This code, which works for the feature requested by Ken, needs to be double checked as it is fully AI generated.

When given a negative radius now creates a new smaller object compared to the original one, considering the radius absolute value.

This allows to create a raster buffer in a second step:

e.g. try in "Bilbao"

model each ecology:Forest earth:Region
	observing landcover:LandCoverType named lct
	using gis.features.extract(select = [lct is landcover:Forest]); 

thing Banana;

private model each Banana
	observing ecology:Forest earth:Region named frg
	using 
		im.geoprocessing.buffer(artifact = frg, radius = -50, subtract = false);
		
thing Buffer;
		
model presence of Buffer
	 observing 
	 presence of Banana named bana,
     presence of ecology:Forest earth:Region named regio
     set to [regio == true && bana == false]
     ;
image

Copy link
Copy Markdown
Contributor

@euskalhenriko euskalhenriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are aesthetic; it seems that the code has not been substantially modified.
These lines should make a difference but they are equal to the previous ones.
New:

// Apply buffer (positive = external, negative = internal)
IShape newShape = workingShape.buffer(bdistance);

Old:

IShape newShape = oshape.buffer(bdistance);

Try entering negative values into the actual code. If this doesn't work, we can check which changes are necessary.

@kbagstad
Copy link
Copy Markdown

kbagstad commented Mar 5, 2026

It does work. Many thanks for your prompt attention to this! I'll make a note in quick tips that negative values for an inner buffer are also possible.

@balbionthebox balbionthebox added the wontfix This will not be worked on label Mar 5, 2026
@balbionthebox
Copy link
Copy Markdown
Member Author

balbionthebox commented Mar 5, 2026

NOTE to keep the handling of collapsed subjects.
The original code produces results pretending that the collapsed subjects still exist.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants