add clipping

This commit is contained in:
Motiejus Jakštys 2020-05-26 15:54:16 +03:00
parent 538557f9a1
commit 1ba8e26957
3 changed files with 34 additions and 6 deletions

View File

@ -29,9 +29,23 @@ def parse_args():
parser.add_argument('-o', '--outfile', metavar='<file>', type=str) parser.add_argument('-o', '--outfile', metavar='<file>', type=str)
parser.add_argument( parser.add_argument(
'--size', type=plt_size, help='Figure size in mm (WWxHH)') '--size', type=plt_size, help='Figure size in mm (WWxHH)')
parser.add_argument(
'--clip', type=float, nargs=4,
metavar=('xmin', 'ymin', 'xmax', 'ymax'))
return parser.parse_args() return parser.parse_args()
#def makebox(t):
# xmin, ymin, xmax, ymax = t
# if xmin > xmax:
# raise Exception("xmin should be > xmax")
# if ymin > ymax:
# raise Exception("ymin should be > ymax")
# left, bottom = xmin, ymin
# width, height = xmax - xmin, ymax - ymin
# return {'left': left, 'bottom': bottom, 'width': width, 'height': height}
def main(): def main():
args = parse_args() args = parse_args()
if args.table: if args.table:
@ -41,8 +55,12 @@ def main():
else: else:
f = geopandas.read_file(args.infile) f = geopandas.read_file(args.infile)
f.plot(figsize=args.size) f.plot(figsize=args.size)
plt.axis('off') ax = plt.gca()
plt.margins(0, 0) if args.clip:
ax.set_ylim(bottom=args.clip[1], top=args.clip[3])
ax.set_xlim(left=args.clip[0], right=args.clip[2])
ax.axis('off')
ax.margins(0, 0)
plt.tight_layout(0) plt.tight_layout(0)
if args.outfile: if args.outfile:
plt.savefig(args.outfile, bbox_inches=0, dpi=300) plt.savefig(args.outfile, bbox_inches=0, dpi=300)

View File

@ -46,6 +46,12 @@ a6: 105x148xmm
a7: 74x105mm a7: 74x105mm
a8: 52x74mm a8: 52x74mm
Xmin: 623306.313
Ymin: 6109635.515
Xmax: 625526.313
Ymax: 6111210.515
623306.313 6109635.515 625526.313 6111210.515
connect rivers first to a single polylines: connect rivers first to a single polylines:
- some algs can preserve connectivity, some not. - some algs can preserve connectivity, some not.
@ -136,14 +142,18 @@ are often used for line generalization:
Review of the available algorithms will be followed by desiderata for a Review of the available algorithms will be followed by desiderata for a
possible open-source addition. In the end, we will issue a recommendation, possible open-source addition. In the end, we will issue a recommendation,
which algorithm can be picked up and implemented by a willing GIS developer. which algorithm can be picked up and implemented by an avid GIS developer.
\section{Visual comparison} \section{Visual comparison}
Lakaja and large part of Žeimena (see figure~\ref{fig:zeimena} on Lakaja and large part of Žeimena (see figure~\ref{fig:zeimena} on
page~\pageref{fig:zeimena}) will be used, because the river exhibits both both page~\pageref{fig:zeimena}) will be used as inputs to the generalization
straight and curved shape, is a combination of two curly rivers, and author's algorithms, because the river exhibits both both straight and curved shape, is
familiarity with the location. a combination of two curly rivers, and author's familiarity with the location.
Since the map area is large (scale $1:150 000$), we will also review a
zoomed-in subset of the map of scale $1:10 000$. The zoomed-in version will
help explain some of the deficiencies in the reviewed algorithms.
\begin{figure}[H] \begin{figure}[H]
\centering \centering

Binary file not shown.